﻿Imports System.Windows
Imports System.Windows.Data

Public Class BooleanVisibilityConverter
    Implements IValueConverter

#Region "IValueConverter Members"

    Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
        Dim boolValue As Boolean = DirectCast(value, Boolean)
        If parameter <> Nothing AndAlso parameter.ToString() = "Inverted" Then
            boolValue = Not boolValue
        End If

        If boolValue Then
            Return Visibility.Visible
        Else
            Return Visibility.Collapsed
        End If
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
        Throw New NotImplementedException()
    End Function
#End Region
End Class
